import request from '@/config/request';

export interface DictItemTypes {
  dictLabel: string;
  dictValue: string | number | undefined;
}

// 查询字典数据详细
export function dictData (dictType: string): Promise<any> {
  return request({
    url: `/system/dict/data/type/${dictType}`,
    method: 'GET'
  })
}

// 根据字典value获取label
export function getDictLabel (dictData: DictItemTypes[], dictValue: string | number | undefined ): string | number | undefined {
  const findItems = dictData.find(v=> v.dictValue === dictValue);
  return findItems ? findItems.dictLabel : undefined
}